import request from '@/utils/request'

//用户管理
const USER_URL = 'api/admin/user/'

//登录
export const login = (data)=>{ //传json格式
    return request.post(USER_URL+'login',data)
}

//根据id查询员工信息
export const queryById = (id)=>{
    return request.get(USER_URL+'/'+id)
}


// //员工分页查询 传参方式1
// export const page = (name,page,pageSize)=>{
//     return request.get('api/admin/user/page?name='+name
//     +'&page='+page
//     +'&pageSize='+pageSize)
// }

//员工分页查询 传参方式2
export const userPage = (name,page,pageSize,storeId)=>{
    return request.get(USER_URL+'page',{
        params:{
            name:name,
            page:page,
            pageSize:pageSize,
            storeId:storeId
        }
    })
}

//新增用户
export const addUser = (user)=>{
    return request.post(USER_URL,user)
}

//编辑用户信息
export const updateUser = (user)=>{
    return request.put(USER_URL,user)
}

//根据商店id查询用户
export const queryUserByStoreId = (storeId)=>{
    return request.put(USER_URL+'queryUserByStoreId/',{
        params:{
            storeId:storeId
        }
    })
}

//根据商店id查询用户(分页)



//启用禁用员工账号
export const statusEdit = (id,status)=>{
    return request.post(USER_URL+'status/'+status,{
        params:{
            id:id
        }
    })
}

//修改密码
export const updatePassword = (id,oldPass,newPass)=>{
    console.log(id,oldPass,newPass)
    // return request.put(USER_URL+'updatePassword',{
    //     params:{
    //         id:id,
    //         oldPassword:oldPass,
    //         newPassword:newPass
    //     }
    // })
    return request.put(USER_URL+'updatePassword?id='+id+'&oldPassword='+oldPass+'&newPassword='+newPass)
}

